/* ============================================================
 * Forms.css - 表单类组件样式
 * 
 * 定义表单相关的UI组件样式
 * 包括：按钮、输入框、选择框、文本域、开关、滑块、单选框、复选框、评分等
 * ============================================================ */

/* 按钮组和主题切换容器 */
.btn-group,
.theme-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

/* 按钮基础样式 */
button,
.btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: 0.2s;
  background-color: var(--trbg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 8px;
}

/* 按钮悬停状态 */
button:hover,
.btn:hover {
  background: var(--btn-hover);
}

/* 表单输入控件基础样式（排除 checkbox 和 radio） */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  margin: 6px 0;
  width: 290px;
  max-width: 100%;
}

/* 复选框和单选框基础样式 */
input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border, #ccc);
  border-radius: 3px;
  background: var(--bg, #fff);
  position: relative;
  cursor: pointer;
  vertical-align: middle;
  margin: 0 4px;
  transition: all 0.2s ease;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  border-color: var(--main, #007aff);
  background: var(--main, #007aff);
}

input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
}

input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}

/* 文本域特殊样式 */
textarea {
  min-height: 80px;
  resize: vertical;
}

/* 标签基础样式 */
label {
  margin-right: 10px;
}

/* 开关控件容器 */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  margin: 6px 0;
}

/* 隐藏原生checkbox */
.switch input {
  opacity: 0;
}

/* 开关滑块 */
.slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}

/* 开关圆形按钮 */
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
}

/* 开关激活状态 */
input:checked+.slider {
  background: var(--main);
}

input:checked+.slider:before {
  transform: translateX(20px);
}

/* 表单项目容器 */
.form-item {
  margin: 12px 0;
}

/* 表单标签 */
.form-label {
  display: block;
  margin-bottom: 4px;
}

/* 滑块输入控件 */
.slider-input {
  -webkit-appearance: none;
  width: 240px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}

/* 滑块拇指样式 */
.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--main);
  cursor: pointer;
}

/* 单选框项目 */
.radio-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

/* 自定义单选框 */
.radio-item input[type="radio"] {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border, #ddd);
  border-radius: 50%;
  background: var(--bg, #fff);
  position: relative;
  transition: all 0.2s ease;
}

/* 单选框选中状态 */
.radio-item input[type="radio"]:checked {
  border-color: var(--main, #007aff);
  background: var(--main, #007aff);
}

.radio-item input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--check-color, #fff);
}

.radio-item label {
  cursor: pointer;
  user-select: none;
}

/* 复选框项目 */
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

/* 自定义复选框 */
.checkbox-item input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border, #ddd);
  border-radius: 4px;
  background: var(--bg, #fff);
  position: relative;
  transition: all 0.2s ease;
}

/* 复选框选中状态 */
.checkbox-item input[type="checkbox"]:checked {
  border-color: var(--main, #007aff);
  background: var(--main, #007aff);
}

.checkbox-item input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--check-color, #fff);
  font-size: 14px;
  font-weight: bold;
}

.checkbox-item label {
  cursor: pointer;
  user-select: none;
}

/* 评分组件 */
.rate {
  color: #ffc107;
  font-size: 20px;
}
